let body = document.querySelector('.body')
let dropdown = document.querySelector('.dropdown-lift')
let dropdowns = document.querySelector('.dropdown-right')
let we = document.querySelector('.pic1')
let you = document.querySelector('.pic2')
let time = document.querySelector('.times')

//发送请求，获取用户数据
renderContents()
async function renderContents(){
    let res = await axios({
        method:'get',
        url:'/api/user',
        params:{
            userId:"632197bd8c0fd333f646d17c"
        }
    })
    //渲染数据
    let data = res.data.data
    // console.log(data);

    renderUserList2(data) 
    function renderUserList2(data) {
    let reminds = '';
        reminds +=`
        <a href="" class="title">${data.username}</a>
        <span class="caret"></span>
        <ul class="userdisplay">
            <li>
                <a href="../lk/my-diary.html">我的日记</a>
            </li>
            <li>
                <a href="guanzhudereng.html">我关注的人</a>
            </li>
            <li>
                <a href="">设置</a>
            </li>
            <li>
                <a href="">退出</a>
            </li>
        </ul>
        `
    dropdowns.innerHTML = reminds
}

  
            let remind = '';
                remind +=`
                    <a href="tixing.html" class="title">提醒(${0})</a>
                    <span class="caret"></span>
                    <ul class="msg">
                        <li>没有提醒</li>
                    </ul>
                `
            dropdown.innerHTML = remind

renderContents()
async function renderContents(){
    let res = await axios({
        method:'get',
        url:'/api/user',
        params:{
            userId:localStorage.getItem("user")
        }
    })
    // console.log(res);
    let html = '';
        html += `
        <a href="../lk/user-diary.html"></a>
            <img class="touxiang" src="../../img/zy-tiuxiang.jpg" alt="">
        </a> 
        <div class="body-text">
            <div class="text">
                <a href="">HCS</a>
                  10 : 31 am 
                <a href="">  《obj》</a>
            </div>
           <div class="daytext">
            <img src="../../img/zy-tiuxiang.jpg" alt="">
            <p>傻逼学校把窗户钉死，只能开一半 你猜是因为什么 因为怕学生跳楼 你妈的图书馆教学楼哪个不能跳只有宿舍能跳？ 宿舍天天闷的臭的跟啥一样我是真受不了了 还有傻逼领导我跟你说 你们这样搞，想自杀的是不在宿舍跳楼了，因为死之前要先去杀了你们，杀遍傻逼领导傻逼学校把窗户钉死 </p>
           </div>
            <div>
                <a href="../ys/reply.html" class="return">2 回复</a>
            </div>
        </div>
        </div>
         `
    body.innerHTML = html
}

getTime()
async function getTime() {
    let res1 = await axios({
      method: "GET",
      url: "/api/user",
      params: {
        userId: localStorage.getItem("user")
      },
    });
    let date = new Date();
    // 获取日期：年月日
    const year = date.getFullYear();
    const month = date.getMonth() + 1;
    const day = date.getDate();
    this.nowDate = month + "/" + day;
    this.nowYear = "/" + year;
  
    // 获取星期几
    const weeks = new Array(
      "星期日",
      "星期一",
      "星期二",
      "星期三",
      "星期四",
      "星期五",
      "星期六"
    );
    this.nowWeek = weeks[new Date().getDay()];
    nowWeek = this.nowWeek;
    nowDate = this.nowDate;
    nowYear = this.nowYear;
  
    console.log(res1);
    userName = res1.data.data.username;
    let imgSrc = res1.data.data.headphoto;
    let beginTime = res1.data.data.createAt
      .replace(/[a-zA-Z]+/g, "")
      .slice(0, 10);
    let description = res1.data.data.description;
    // console.log(userName);
    let html = `
        <span>${nowDate}</span>
        <span class="time">
            <span>${nowWeek}</span>
            <span>${nowYear}</span>
        </span>
    `
    time.innerHTML = html
}




    let html1 = '';
        html1 += `
        <a href="">
            <img src="../../img/zy-tiuxiang.jpg" alt="">
        </a>
        <a href="">
            HCS
        </a>
         `
    we.innerHTML = html1
    let html2 = '';
        html2 += `
        <a href="">
            <img src="../../img/zy-tiuxiang.jpg" alt="">
        </a>
        <a href="">
            HCS
        </a>
         `
    you.innerHTML = html2
}